# coding=utf-8
# 元组 列表用[]，元组用 ()且不能修改

"""
tup = ("hello")  # str型
tup = ("hello",)  # tuple型
tup1 = tuple("hello")
print(tup1)
del tup1  # delete

tup = ("hello", "yep", "nope")
tup3 = (random.randint(1, 100) for i in range(1, 10))
print(tup3)
print(tuple(tup3))

dic1 = {}
dic1 = dict()  # 空字典创建
dic = {"1": "emma", "2": "jane", "3": "summer"}
print(dic)

list1 = [1, 2, 3, 4, 5]
tup1 = ("a", "b", "c", "d")
dic2 = dict(zip(list1, tup1))
print(dic2)  # zip一一对应 推广：dict可换成list,tuple
print(dic2[1])  # []中放的是key值
print(dict.get(dic2, 1))  # 查找key对应值
for nn in dic2.items():  # 遍历
    print(nn)
for kk,vv in dic2.items():  # 遍历
    print("key:",str(kk))
    print("value:", str(vv))

del dic[1]
dic2 = dict.fromkeys(list1)  # 创建字典，None
print(dic2)
"""
# 集合set
# ① {}直接创建
# ② set()函数，例：set(list1)
set1 = {1, 2, 3, 4, 5, 6}
set1.add(100)
print(set1)
set1.pop()  # 删除栈顶，即第一个
set1.remove(5)  # ()放集合中的一个元素
set1.clear  # 清空
ss1 = {"as", "er", "fg", "bb"}
ss2 = {"df", "er", "bb"}
s1=ss1 & ss2  # 交集
print(s1)
s2=ss1 | ss2  # 并集
print(s2)
s3=ss1 - ss2  # 差集
print(s3)
s4=ss1 ^ ss2 # 对称差集：都有的去掉，剩下的合并
print(s4)